package cn.dt70.service.impl;

import cn.dt70.dao.aqbPacketsandinterest.AqbPacketsandinterestMapper;
import cn.dt70.service.AqbPacketsandinterestService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("AqbPacketsandinterestService")
public class AqbPacketsandinterestServiceImpl implements AqbPacketsandinterestService {

    private static final Logger LOGGER = Logger.getLogger(AqbPacketsandinterestServiceImpl.class);

    @Resource
    private AqbPacketsandinterestMapper aqbPacketsandinterestMapper;

    @Override
    public int qrytypeValueforstock(Double typeValue) {
        int stock = 0;

        try {
            stock=aqbPacketsandinterestMapper.qryBytypeValueforstock(typeValue);
            LOGGER.debug("aqbPacketsandinterestMapper.qryBytypeValueforstock查询成功");
            return stock;
        } catch (Exception e) {
            LOGGER.debug("aqbPacketsandinterestMapper.qryBytypeValueforstock查询异常"+e.getMessage());

        }
        return stock;
    }

    @Override
    public boolean updateHongbaoStock(Integer stock, String typeCode) {
        int row=0;
        try {
            row=aqbPacketsandinterestMapper.updateStock(stock,typeCode);
            if(row==1){
                LOGGER.debug("aqbPacketsandinterestMapper.updateStock 修改成功");
                return true;
            }else{
                LOGGER.debug("aqbPacketsandinterestMapper.updateStock 修改失败");
                return false;
            }
        } catch (Exception e) {
            LOGGER.error("aqbPacketsandinterestMapper.updateStock 修改异常"+e.getMessage());
            return false;
        }
    }
}
